<template>
  <!-- 放置一个图标 -->
  <div>
    <svg-icon :icon-class="isScreenFull ? 'exit-fullscreen':'fullscreen'" class="fullscreen" @click="screenFullFn" />
  </div>
</template>

<script>
import screenfull from 'screenfull'
export default {
  name: 'ScreenFull',
  data() {
    return {
      isScreenFull: false
    }
  },
  mounted() {
    //  监听全屏状态
    // 当全屏状态发生变化的时候，会触发
    screenfull.on('change', () => {
      this.isScreenFull = screenfull.isFullscreen
    })
  },
  methods: {
    screenFullFn() {
      //
      this.isScreenFull = true
      screenfull.toggle()
    }
  }
}
</script>

   <style lang="scss" scoped>
   .fullscreen {
     width: 20px;
     height: 20px;
     color: #fff;
     cursor: pointer;
   }
   </style>

